<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>AMIS动态页面</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta http-equiv="Access-Control-Allow-Origin" content="*">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="icon" href="/images/favicon.ico">

    <meta http-equiv="expires" content="0">
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="cache-control" content="no-cache">

    <!--layui-->
    <script src="/plugin/layui/layui.js" charset="utf-8"></script>
    <script src="/plugin/jquery/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script src="/plugin/jquery/jquery.blockUI.js" type="text/javascript"></script>
    <script src="/plugin/base.tools.js" type="text/javascript"></script>
    <script src="/plugin/jquery/jquery.cookie.js" type="text/javascript"></script>
    <script src="/plugin/json/json2.js" type="text/javascript"></script>
    <link rel="stylesheet" href="/plugin/layui/css/layui.css">

    <!--amis-->
    <link rel="stylesheet" href="/amis/sdk.css"/>
    <link rel="stylesheet" href="/amis/helper.css"/>
    <link rel="stylesheet" href="/amis/iconfont.css"/>
    <style>
        html, body, .app-wrapper {
            position: relative;
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }
    </style>
</head>
<body>
<div id="root" class="app-wrapper"></div>
<!--amis-->
<script src="/amis/sdk.js"></script>
<script type="text/javascript">
    (function () {
        let amis = amisRequire('amis/embed');
        // 通过替换下面这个配置来生成不同页面
        let amisJSON = {
            "type": "page",
            "title": "动态页面管理",
            "body": [
                {
                    "type": "crud",
                    "syncLocation": false,
                    "api": {
                        "method": "get",
                        "url": "/demo/query",
                        "requestAdaptor": "",
                        "adaptor": "",
                        "messages": {}
                    },
                    "bulkActions": [],
                    "itemActions": [],
                    "filterSettingSource": [
                        "amisJson",
                        "attrId",
                        "attrName"
                    ],
                    "features": [
                        "create",
                        "filter",
                        "update",
                        "delete"
                    ],
                    "filterColumnCount": 3,
                    "filterEnabledList": [
                        {
                            "label": "attrName",
                            "value": "attrName"
                        }
                    ],
                    "headerToolbar": [
                        {
                            "label": "新增",
                            "type": "button",
                            "actionType": "dialog",
                            "level": "primary",
                            "dialog": {
                                "title": "新增",
                                "body": {
                                    "type": "form",
                                    "api": {
                                        "method": "post",
                                        "url": "/demo/add",
                                        "requestAdaptor": "",
                                        "adaptor": "",
                                        "messages": {}
                                    },
                                    "body": [
                                        {
                                            "type": "input-text",
                                            "name": "amisJson",
                                            "label": "页面JSON",
                                            "id": "u:c45167f86c8b"
                                        },
                                        {
                                            "type": "input-text",
                                            "name": "attrId",
                                            "label": "标签ID",
                                            "id": "u:91bb37c082fa"
                                        },
                                        {
                                            "type": "input-text",
                                            "name": "attrName",
                                            "label": "标签名称",
                                            "id": "u:0a3245c63b21"
                                        }
                                    ],
                                    "id": "u:825e2bc212e8"
                                }
                            },
                            "id": "u:38cb8beec9d7",
                            "align": "left"
                        },
                        {
                            "type": "bulk-actions",
                            "align": "right"
                        }
                    ],
                    "filter": {
                        "title": "",
                        "submitText": "",
                        "id": "u:6b0da3c9422e",
                        "body": [
                            {
                                "type": "input-text",
                                "name": "keywords",
                                "placeholder": "请输入标签名称",
                                "addOn": {
                                    "label": "搜索",
                                    "type": "submit"
                                }
                            },
                            {
                                "type": "plain",
                                "text": "支持模糊搜索"
                            }
                        ]
                    },
                    "id": "u:6a60c8ef5922",
                    "perPageAvailable": [
                        10
                    ],
                    "messages": {},
                    "bodyClassName": "",
                    "filterTogglable": true,
                    "alwaysShowPagination": true,
                    "mode": "cards",
                    "defaultParams": {
                        "perPage": 20
                    },
                    "filterDefaultVisible": true,
                    "autoFillHeight": false,
                    "pageField": "page",
                    "card": {
                        "type": "card",
                        "header": {
                            "title": "${attrName}",
                            "subTitle": ""
                        },
                        "body": [
                            {
                                "label": "标签ID",
                                "type": "text",
                                "name": "attrId",
                                "id": "u:3687d685da7a"
                            },
                            {
                                "label": "标签名称",
                                "type": "text",
                                "name": "attrName",
                                "id": "u:52dd9b989c78"
                            }
                        ],
                        "actions": [
                            {
                                "type": "button",
                                "label": "打开",
                                "onEvent": {
                                    "click": {
                                        "actions": [
                                            {
                                                "ignoreError": false,
                                                "actionType": "custom",
                                                "args": {},
                                                "script": (context, doAction, event) => {
                                                    window.parent.menuInitByParam(event.data.attrId, 'dynamicPage', event.data.attrName)
                                                }
                                            }
                                        ]
                                    }
                                },
                                "id": "u:999144d1cd78"
                            },
                            {
                                "label": "编辑",
                                "type": "button",
                                "actionType": "dialog",
                                "level": "link",
                                "dialog": {
                                    "title": "编辑",
                                    "body": {
                                        "type": "form",
                                        "api": "demo/update",
                                        "body": [
                                            {
                                                "label": "页面JSON",
                                                "name": "amisJson",
                                                "type": "input-text",
                                                "id": "u:bb8c068fd627"
                                            },
                                            {
                                                "label": "标签ID",
                                                "name": "attrId",
                                                "type": "input-text",
                                                "id": "u:cf9fb89c4f6e"
                                            },
                                            {
                                                "label": "标签名称",
                                                "name": "attrName",
                                                "type": "input-text",
                                                "id": "u:eb3e861eedf1"
                                            }
                                        ],
                                        "id": "u:d2c494032ae7"
                                    }
                                },
                                "id": "u:6cb19a499b02"
                            },
                            {
                                "type": "button",
                                "label": "删除",
                                "actionType": "ajax",
                                "level": "link",
                                "className": "text-danger",
                                "confirmText": "确定要删除？",
                                "api": {
                                    "method": "post",
                                    "url": "/demo/query",
                                    "requestAdaptor": "",
                                    "adaptor": "",
                                    "messages": {}
                                },
                                "id": "u:79792050c45f"
                            }
                        ],
                        "id": "u:863797dd0bb7",
                        "actionsCount": 3,
                        "bodyClassName": "",
                        "titleClassName": ""
                    }
                }
            ],
            "id": "u:d81b4bb199fe",
            "asideResizor": false,
            "pullRefresh": {
                "disabled": true
            },
            "regions": [
                "body",
                "header"
            ],
            "themeCss": {
                "titleControlClassName": {
                    "font:default": {}
                }
            }
        };
        let amisScoped = amis.embed('#root', amisJSON);
    })();


    // var element, layer;
    //
    // layui.use(['element', 'layer'], function () {
    //     element = layui.element;
    //     layer = layui.layer;
    // });
    //
    // function menuInit(id, href, name) {
    //     if (href != null && href !== "" && href.length > 1 && href !== "null") {
    //         element.tabAdd('menubody', {
    //             title: name
    //             , content: "<iframe style='width: 100%;height: 800px' src='" + href + "'></iframe>"
    //             , id: id
    //         });
    //     }
    //     //切换到：用户管理
    //     element.tabChange('menubody', id);
    // }
</script>
</body>
</html>
